<template>
  <div class="schedulecalendar">
    <el-dialog
      :visible.sync="isShow"
      id="scroll"
      :before-close="closeScheule"
      :close-on-click-modal="modalclose"
      custom-class="el-calenlar-dialog-bg"
    >
      <div class="schedule-box" v-if="classInfo">
        <div class="class-name">
          <span class="spanlabelimp">{{param.classInfo.className}}</span>
        </div>
        <div class="class-Info">
          <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
            <tr>
              <td>
                <span class="spanlabel">课程名称：</span>
                <span class="spanlabelweight">{{param.classInfo.courseName}}</span>
              </td>
              <td>
                <span class="spanlabel">科目：</span>
                <span class="spanlabelweight">{{param.classInfo.subjectName}}</span>
              </td>
              <td>
                <span class="spanlabel">课程类型：</span>
                <span class="spanlabelweight">{{coursetypeObj[param.classInfo.courseTypeId]}}</span>
                <!--<span class="spanlabelweight" v-if="param.classInfo.courseTypeId==1">一对一</span>
		        		 		<span class="spanlabelweight" v-else-if="param.classInfo.courseTypeId==2">班课（全日/半日）</span>
		        		 		<span class="spanlabelweight" v-else-if="param.classInfo.courseTypeId==3">班课（普通）</span>
                <span class="spanlabelweight" v-else-if="param.classInfo.courseTypeId==4">双师</span>-->
              </td>
              <td>
                <span class="spanlabel">授课模式：</span>
                <span class="spanlabelweight" v-if="param.classInfo.courseMode==1">大班课</span>
                <span class="spanlabelweight" v-else-if="param.classInfo.courseMode==2">中班课</span>
                <span class="spanlabelweight" v-else-if="param.classInfo.courseMode==3">小班课</span>
              </td>
            </tr>
            <tr>
              <td>
                <span class="spanlabel">课程总时数：</span>
                <span class="spanlabelweight" v-if="param.classInfo.courseTypeId==2">
                  <span>{{param.classInfo.totalCourseHour}}</span>
                  <span v-if="param.classInfo.courseTimeMode=='1'">(年)</span>
                  <span v-else-if="param.classInfo.courseTimeMode=='2'">(半年)</span>
                  <span v-else-if="param.classInfo.courseTimeMode=='3'">(季)</span>
                  <span v-else-if="param.classInfo.courseTimeMode=='4'">(月)</span>
                  <span v-else-if="param.classInfo.courseTimeMode=='5'">(周)</span>
                </span>
                <span
                  class="spanlabelweight"
                  v-else-if="param.classInfo.courseTypeId==4"
                >{{param.classInfo.totalCourseHour}}节</span>
                <span class="spanlabelweight" v-else>{{param.classInfo.totalCourseHour}}个课时</span>
              </td>
              <td>
                <span class="spanlabel" v-if="param.classInfo.courseTypeId==2">每次上课：</span>
                <span class="spanlabel" v-else>单次消课数：</span>
                <span class="spanlabelweight" v-if="param.classInfo.courseTypeId==2">1天</span>
                <span class="spanlabelweight" v-else-if="param.classInfo.courseTypeId==4">1节</span>
                <span class="spanlabelweight" v-else>{{param.classInfo.oneCourseHour}}课时</span>
              </td>
              <td>
                <span class="spanlabel" v-if="param.classInfo.courseTypeId==2">每天：</span>
                <span class="spanlabel" v-else>单次课程时间：</span>
                <span
                  class="spanlabelweight"
                  v-if="param.classInfo.courseTypeId==2"
                >{{param.classInfo.SumHour}}小时</span>
                <!--<span class="spanlabelweight" v-else-if="param.classInfo.courseTypeId==4">{{param.classInfo.oneCourseHourMinute}}分钟</span>-->
                <span class="spanlabelweight" v-else>{{param.classInfo.oneCourseHourMinute}}分钟</span>
              </td>
              <td>
                <span class="spanlabel">开班时间：</span>
                <span class="spanlabelweight">{{param.classInfo.startTime}}</span>
              </td>
            </tr>
            <tr>
              <td>
                <span class="spanlabel">教师：</span>
                <span class="spanlabelweight">{{param.classInfo.teacherUserName}}</span>
              </td>
              <td>
                <span class="spanlabel">助教：</span>
                <span class="spanlabelweight">{{param.classInfo.assisUserName}}</span>
              </td>
              <td>
                <span class="spanlabel">教室：</span>
                <span class="spanlabelweight">{{param.classInfo.classRoomName}}</span>
              </td>
              <td></td>
            </tr>
          </table>
        </div>
        <div class="line"></div>
        <div class="calendar-content">
          <div class="left-content">
            <!--课程列表框-->
            <div class="condition-box">
              <el-input
                placeholder="请输入课程名称"
                @input="querycourseList"
                v-if="param.classInfo.courseTypeId==2"
                v-model="param.course"
                style="padding:0.1rem;"
              >
                <div class="prefixiconsearch" slot="prefix"></div>
              </el-input>
              <el-input
                placeholder="请输入课程名称"
                @input="querycourseList"
                disabled
                v-else
                v-model="param.course"
                style="padding:0.1rem;"
              >
                <div class="prefixiconsearch" slot="prefix"></div>
              </el-input>
              <div class="condition-list" v-if="param.classInfo.courseTypeId==2">
                <div class="condition-li" v-for="li in tempcourselist">
                  <div :class="li.styleclass" @dblclick="reCheck(li)" @click="changeCheck(1,li)">
                    <span :title="li.name" class="spanlabel">{{li.name}}</span>
                  </div>
                </div>
              </div>
              <div class="condition-list" v-else>
                <div class="condition-li" v-for="li in tempcourselist">
                  <div :class="li.styleclass" style="cursor: not-allowed;">
                    <span :title="li.name" class="spanlabel">{{li.name}}</span>
                  </div>
                </div>
              </div>
            </div>
            <!--教师列表框-->
            <div class="condition-box">
              <el-input
                placeholder="请输入教师名称"
                @input="queryteacherList"
                v-model="param.teacher"
                style="padding:0.1rem;"
              >
                <div class="prefixiconsearch" slot="prefix"></div>
              </el-input>
              <div class="condition-list">
                <div class="condition-li" v-for="li in tempteacherlist">
                  <div :class="li.styleclass" @click="changeCheck(2,li)">
                    <span :title="li.name" class="spanlabel">{{li.name}}</span>
                  </div>
                </div>
              </div>
            </div>
            <!--助教列表框-->
            <div class="condition-box">
              <el-input
                placeholder="请输入助教名称"
                @input="queryasisterList"
                v-model="param.assister"
                style="padding:0.1rem;"
              >
                <div class="prefixiconsearch" slot="prefix"></div>
              </el-input>
              <div class="condition-list">
                <div class="condition-li" v-for="li in tempassistlist">
                  <div :class="li.styleclass" @click="changeCheck(3,li)">
                    <span :title="li.name" class="spanlabel">{{li.name}}</span>
                  </div>
                </div>
              </div>
            </div>
            <!--教室列表框-->
            <div class="condition-box">
              <el-input
                placeholder="请输入教室名称"
                @input="queryclassroomList"
                v-model="param.classroom"
                style="padding:0.1rem;"
              >
                <div class="prefixiconsearch" slot="prefix"></div>
              </el-input>
              <div class="condition-list">
                <div class="condition-li" v-for="li in tempclassroomlist">
                  <div :class="li.styleclass" @click="changeCheck(4,li)">
                    <span :title="li.name" class="spanlabel">{{li.name}}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="right-content">
            <div class="calendarcontainer">
              <syllabusCalendar
                :syllabusData="param"
                @parentMethods="parentMethods"
                ref="syllabusControl"
              ></syllabusCalendar>
            </div>

            <div class="box-controls">
              <div class="avoid-holiday">
                <span class="spanlabel" style="align-self:center;">避开</span>
                <div style="align-self:center;margin-left: 0.2rem;width:5rem;">
                  <el-radio v-model="param.holidayradio" @change="selectType" label="1">周末</el-radio>
                  <el-radio v-model="param.holidayradio" @change="selectType" label="2">节假日</el-radio>
                </div>
              </div>
              <div class="set-timetable-cycle">
                <span class="spanlabel" style="align-self:center;">设置列表重复频率</span>
                <div
                  style="align-self:center;margin-left: 0.2rem;width:5rem;"
                  v-if="classInfo.classOrTrialClass==2&&classInfo.courseType==4"
                >
                  <el-radio v-model="param.radio" disabled label="1">每周</el-radio>
                  <el-radio v-model="param.radio" disabled label="2">隔周</el-radio>
                  <el-radio v-model="param.radio" disabled label="3">按月</el-radio>
                  <el-radio v-model="param.radio" disabled label="0">不重复</el-radio>
                </div>
                <div style="align-self:center;margin-left: 0.2rem;width:5rem;" v-else>
                  <el-radio v-model="param.radio" label="1">每周</el-radio>
                  <el-radio v-model="param.radio" label="2">隔周</el-radio>
                  <el-radio v-model="param.radio" label="3">按月</el-radio>
                  <el-radio v-model="param.radio" label="0">不重复</el-radio>
                </div>
              </div>
              <div class="timetable-Application-cycle" v-if="param.classInfo.courseTypeId==2">
                <span class="spanlabel" style="align-self:center;">设置课表应用周期</span>
                <div style="align-self:center;margin-left: 0.2rem;width:5rem;">
                  <el-date-picker
                    v-model="param.startDate"
                    value-format="yyyy-MM-dd"
                    type="date"
                    placeholder="选择开课日期"
                  ></el-date-picker>
                  <el-date-picker
                    v-model="param.endDate"
                    value-format="yyyy-MM-dd"
                    type="date"
                    placeholder="选择结课日期"
                  ></el-date-picker>
                </div>
              </div>
              <div class="save-timetable-btn">
                <div class="success" @click="SaveCourseSchedule">保存排课</div>
                <div style="width:0.2rem;"></div>
                <div class="info" @click="saveCancel">取消</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>

    <!--排课-->
    <el-dialog
	  id="paike"
      :visible.sync="newcalendar.isShow"
      :close-on-click-modal="modalclose"
      custom-class="class-scheduling"
    >
      <div class="select-class-panel" v-if="classInfo">
        <div class="title-box">
          <span>排课</span>
        </div>
        <div class="scheduling-coursename" v-if="param.classInfo.courseTypeId==2">
          <span>排课课程：</span>
          <span>{{param.courseName}}</span>
        </div>
        <div class="scheduling-box">
          <div class="scheduling-input-num">
            <span>每周上课</span>
            <el-input-number
              v-model="newcalendar.schedulingTimes"
              @change="changetimes"
              v-if="classInfo.classOrTrialClass==2&&classInfo.courseType==4"
              :min="0"
              :max="1"
              label="描述文字"
            ></el-input-number>
            <el-input-number
              v-model="newcalendar.schedulingTimes"
              @change="changetimes"
              v-else
              :min="0"
              :max="10"
              label="描述文字"
            ></el-input-number>
            <span>次</span>
          </div>
          <div class="scheduling-info-box">
            <table border="0" style="width:100%;" cellpadding="0" cellspacing="0">
              <tr
                v-for="li in newcalendar.tempschedulinglist"
                v-if="li.newItem"
                style="height: 0.6rem;"
              >
                <td style="width:1rem;">
                  <span v-if="li.editor" style="color:red;">第{{li.index}}次课</span>
                  <span v-else>第{{li.index}}次课</span>
                </td>
                <td align="center" style="width:1rem;">
                  <el-select
                    ref="selectWeek"
                    style="border:1px solid #5ed37a;border-radius: 0.04rem;"
                    @change="selectWeek(li)"
                    v-model="li.week"
                    placeholder="星期"
                  >
                    <el-option
                      v-for="i in newcalendar.weeks"
                      :key="i.value"
                      :label="i.name"
                      :value="i.value"
                    ></el-option>
                  </el-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-if="param.classInfo.courseTypeId==3||param.classInfo.courseTypeId==4||param.classInfo.courseTypeId==5"
                >
                  <el-time-select
                    @change="selectStartTime(li)"
                    :clearable="newcalendar.isClose"
                    style="border:1px solid #5ed37a;width:1.2rem;border-radius: 0.04rem;"
                    placeholder="上课时间"
                    v-model="li.starttime"
                    :picker-options="{
					                            start: param.classInfo.dayStartTime,
					                            step: '00:05',
					                            end: param.classInfo.dayEndTime
					                          }"
                  ></el-time-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-else-if="param.classInfo.courseTypeId==2"
                >
                  <el-time-select
                    @change="selectAllStartTime(li)"
                    :clearable="newcalendar.isClose"
                    style="width:1.2rem;"
                    placeholder="上课时间"
                    v-model="li.starttime"
                    :picker-options="{
					                            start: param.classInfo.dayStartTime,
					                            step: '00:05',
					                            end: param.classInfo.dayEndTime
					                          }"
                  ></el-time-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-if="param.classInfo.courseTypeId==3||param.classInfo.courseTypeId==4||param.classInfo.courseTypeId==5"
                >
                  <el-time-select
                    ref="selectEndTime"
                    style="border:1px solid #5ed37a;width:1.2rem;border-radius: 0.04rem;"
                    placeholder="结束时间"
                    v-model="li.endTime"
                    disabled
                    :picker-options="{
					                            start: '08:00',
					                            step: '00:01',
					                            end: '21:00'
					                          }"
                  ></el-time-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-else-if="param.classInfo.courseTypeId==2"
                >
                  <el-time-select
                    @change="selectAllEndTime(li)"
                    style="border:1px solid #5ed37a;width:1.2rem;border-radius: 0.04rem;"
                    placeholder="结束时间"
                    v-model="li.endTime"
                    disabled
                    :picker-options="{
					                             start: param.classInfo.dayStartTime,
					                             step: '00:05',
					                             end: param.classInfo.dayEndTime
					                          }"
                  ></el-time-select>
                </td>
                <td align="center" style="width:1rem;">
                  <span
                    v-if="param.classInfo.courseTypeId==2"
                  >{{param.classInfo.oneCourseHourMinute}}分钟</span>
                  <span v-else-if="param.classInfo.courseTypeId==4">1节</span>
                  <span v-else>{{param.classInfo.oneCourseHour}}课时</span>
                </td>
                <td align="center" style="width:1.2rem;">
                  <el-select
                    style="border:1px solid #5ed37a;width:1rem;border-radius: 0.04rem;"
                    ref="teacher"
                    @change="changeLi(1,li)"
                    v-model="li.teacher"
                    placeholder="教师"
                  >
                    <el-option
                      v-for="i in newcalendar.teacher"
                      :key="i.Id"
                      :label="i.name"
                      :value="i.Id"
                    ></el-option>
                  </el-select>
                </td>
                <td align="center" style="width:1.2rem;">
                  <el-select
                    style="border:1px solid #5ed37a;width:1rem;border-radius: 0.04rem;"
                    clearable
                    ref="asssister"
                    @change="changeLi(2,li)"
                    v-model="li.assister"
                    placeholder="助教"
                  >
                    <el-option
                      v-for="i in newcalendar.asssister"
                      :key="i.Id"
                      :label="i.name"
                      :value="i.Id"
                    ></el-option>
                  </el-select>
                </td>
                <td align="center" style="width:1.2rem;">
                  <el-select
                    style="border:1px solid #5ed37a;width:1rem;border-radius: 0.04rem;"
                    ref="classroom"
                    @change="changeLi(3,li)"
                    v-model="li.classroom"
                    placeholder="教室"
                  >
                    <el-option
                      v-for="i in newcalendar.classroom"
                      :key="i.Id"
                      :label="i.name"
                      :value="i.Id"
                    ></el-option>
                  </el-select>
                </td>
                <td align="center" style="width:0.5rem;cursor: pointer;">
                  <i class="el-icon-close" @click="delele(li)"></i>
                </td>
              </tr>
              <tr v-else style="height: 0.6rem;">
                <td style="width:1rem;">
                  <span v-if="li.editor" style="color:red;">第{{li.index}}次课</span>
                  <span v-else>第{{li.index}}次课</span>
                </td>
                <td align="center" style="width:1rem;">
                  <el-select
                    ref="selectWeek"
                    @change="selectWeek(li)"
                    v-model="li.week"
                    placeholder="星期"
                  >
                    <el-option
                      v-for="i in newcalendar.weeks"
                      :key="i.value"
                      :label="i.name"
                      :value="i.value"
                    ></el-option>
                  </el-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-if="param.classInfo.courseTypeId==3||param.classInfo.courseTypeId==4||param.classInfo.courseTypeId==5"
                >
                  <el-time-select
                    ref="selectStartTime"
                    @change="selectStartTime(li)"
                    :clearable="newcalendar.isClose"
                    style="width:1.2rem;"
                    placeholder="上课时间"
                    v-model="li.starttime"
                    :picker-options="{
					                            start: param.classInfo.dayStartTime,
					                            step: '00:05',
					                            end: param.classInfo.dayEndTime
					                          }"
                  ></el-time-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-else-if="param.classInfo.courseTypeId==2"
                >
                  <el-time-select
                    @change="selectAllStartTime(li)"
                    :clearable="newcalendar.isClose"
                    style="width:1.2rem;"
                    placeholder="上课时间"
                    v-model="li.starttime"
                    :picker-options="{
					                            start: param.classInfo.dayStartTime,
					                            step: '00:05',
					                            end: param.classInfo.dayEndTime
					                          }"
                  ></el-time-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-if="param.classInfo.courseTypeId==3||param.classInfo.courseTypeId==4||param.classInfo.courseTypeId==5"
                >
                  <el-time-select
                    ref="selectEndTime"
                    style="width:1.2rem;"
                    placeholder="结束时间"
                    v-model="li.endTime"
                    disabled
                    :picker-options="{
					                            start: '08:00',
					                            step: '00:01',
					                            end: '21:00'
					                          }"
                  ></el-time-select>
                </td>
                <td
                  align="center"
                  style="width:1.4rem;"
                  v-else-if="param.classInfo.courseTypeId==2"
                >
                  <el-time-select
                    @change="selectAllEndTime(li)"
                    style="width:1.2rem;"
                    placeholder="结束时间"
                    v-model="li.endTime"
                    disabled
                    :picker-options="{
					                             start: param.classInfo.dayStartTime,
					                             step: '00:05',
					                             end: param.classInfo.dayEndTime
					                          }"
                  ></el-time-select>
                </td>
                <td align="center" style="width:1rem;">
                  <span
                    v-if="param.classInfo.courseTypeId==2"
                  >{{param.classInfo.oneCourseHourMinute}}分钟</span>
                  <span v-else-if="param.classInfo.courseTypeId==4">1节</span>
                  <span v-else>{{param.classInfo.oneCourseHour}}课时</span>
                </td>
                <td align="center" style="width:1.2rem;">
                  <el-select
                    style="width:1rem;"
                    ref="teacher"
                    @change="changeLi(1,li)"
                    v-model="li.teacher"
                    placeholder="教师"
                  >
                    <el-option
                      v-for="i in newcalendar.teacher"
                      :key="i.Id"
                      :label="i.name"
                      :value="i.Id"
                    ></el-option>
                  </el-select>
                </td>
                <td align="center" style="width:1.2rem;">
                  <el-select
                    style="width:1rem;"
                    ref="asssister"
                    @change="changeLi(2,li)"
                    clearable
                    v-model="li.assister"
                    placeholder="助教"
                  >
                    <el-option
                      v-for="i in newcalendar.asssister"
                      :key="i.Id"
                      :label="i.name"
                      :value="i.Id"
                    ></el-option>
                  </el-select>
                </td>
                <td align="center" style="width:1.2rem;">
                  <el-select
                    style="width:1rem;"
                    ref="classroom"
                    @change="changeLi(3,li)"
                    v-model="li.classroom"
                    placeholder="教室"
                  >
                    <el-option
                      v-for="i in newcalendar.classroom"
                      :key="i.Id"
                      :label="i.name"
                      :value="i.Id"
                    ></el-option>
                  </el-select>
                </td>
                <td align="center" style="width:0.5rem;cursor: pointer;">
                  <i class="el-icon-close" @click="delele(li)"></i>
                </td>
              </tr>
            </table>
          </div>
        </div>
        <div class="Btn-box">
          <div class="success" @click="schedulingOk">确认</div>
          <div style="width:0.2rem;"></div>
          <div class="info" @click="schedulingCancel">取消</div>
          <!--<el-button type="info" @click="schedulingCancel" style="width:1.5rem;font-size: 0.16rem;" round >取消</el-button>
          <el-button type="success" @click="schedulingOk" style="width:1.5rem;font-size: 0.16rem;" round>确认</el-button>-->
        </div>
      </div>
    </el-dialog>

    <!--冲突列表-->
    <el-dialog
	  id="conflict"
      :visible.sync="conflict.isShow"
      :close-on-click-modal="modalclose"
      custom-class="conflict-list"
    >
      <div class="conflict-table" v-if="classInfo">
        <div class="title-box">
          <span>排课</span>
        </div>

        <table style="width:100%;" cellpadding="0" cellspacing="0">
          <thead>
            <tr>
              <th style="width:0.5rem;"></th>
              <th style="width:1rem;">课节序号</th>
              <th style="width:4.88rem;">上课时间</th>
              <th style="width:2rem;">课程名称</th>
              <th style="width:1rem;">教师</th>
              <th style="width:2rem;">教室</th>
            </tr>
          </thead>
          <tbody>
            <tr
              v-for="li in conflict.syllabusList"
              v-if="li.curClasstime.conflictType==1||li.curClasstime.conflictType==2"
              style="color:red;"
            >
              <td align="center">
                <span>冲突</span>
              </td>
              <td align="center">
                <span>第{{li.curClasstime.orderBy}}次课</span>
              </td>
              <td align="center">
                <span>{{li.curClasstime.startTime.split(" ")[0]}}</span>
                <span>{{li.curClasstime.week}}</span>
                <span>{{li.curClasstime.startTime.split(" ")[1]}}-{{li.curClasstime.endTime.split(" ")[1]}}</span>
              </td>
              <td align="center">{{li.curClasstime.courseName||""}}</td>
              <td align="center">{{li.curClasstime.teacherUserName}}</td>
              <td align="center">{{li.curClasstime.classroomName}}</td>
            </tr>
            <tr v-else>
              <td align="center">
                <span></span>
              </td>
              <td align="center">
                <span>第{{li.curClasstime.orderBy}}次课</span>
              </td>
              <td align="center">
                <span>{{li.curClasstime.startTime.split(" ")[0]}}</span>
                <span>{{li.curClasstime.week}}</span>
                <span>{{li.curClasstime.startTime.split(" ")[1]}}-{{li.curClasstime.endTime.split(" ")[1]}}</span>
              </td>
              <td align="center">{{li.curClasstime.courseName||""}}</td>
              <td align="center">{{li.curClasstime.teacherUserName}}</td>
              <td align="center">{{li.curClasstime.classroomName}}</td>
            </tr>
          </tbody>
        </table>

        <div class="conflict-detail">
          <div class="conflict-li" v-for="li in conflict.syllabusList">
            <span v-if="li.curClasstime">
              <!--教师冲突-->
              <span v-if="li.curClasstime.conflictType==1">
                <span
                  style="color: red;"
                >提醒：第{{li.curClasstime.orderBy}}次课的{{li.curClasstime.teacherUserName}}老师有上课时间冲突</span>
                &nbsp;&nbsp;
                <span @click="checkDetail(li)" style="cursor: pointer;">查看详情</span>
                <el-collapse-transition>
                  <div class="conflict" v-if="li.curClasstime.show">
                    <table style="width:100%;" cellpadding="0" cellspacing="0">
                      <thead>
                        <tr>
                          <th>教师名称</th>
                          <th>教室名称</th>
                          <th>班级名称</th>
                          <th>课程名称</th>
                          <th>上课时间</th>
                          <th>课次</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr v-for="row in li.conflictClasstime">
                          <td align="center" style="color: red;">{{row.teacherUserName}}</td>
                          <td align="center">{{row.classroomName}}</td>
                          <td align="center">{{row.className}}</td>
                          <td align="center">{{row.courseName}}</td>
                          <td align="center">
                            {{row.startTime}}&nbsp;&nbsp;
                            {{row.week}}&nbsp;&nbsp;
                            {{row.startTime}}
                            -
                            {{row.endTime}}
                          </td>
                          <td align="center">第{{row.orderBy}}次课</td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </el-collapse-transition>
              </span>
              <!--教室冲突-->
              <span v-if="li.curClasstime.conflictType==2">
                <span
                  style="color: red;"
                >提醒：第{{li.curClasstime.orderBy}}次课的{{li.curClasstime.classroomName}}教室有上课时间冲突</span>
                &nbsp;&nbsp;
                <span @click="checkDetail(li)" style="cursor: pointer;">查看详情</span>
                <el-collapse-transition>
                  <div class="conflict" v-if="li.curClasstime.show">
                    <table style="width:100%;" cellpadding="0" cellspacing="0">
                      <thead>
                        <tr>
                          <th>教师名称</th>
                          <th>教室名称</th>
                          <th>班级名称</th>
                          <th>课程名称</th>
                          <th>上课时间</th>
                          <th>课次</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr v-for="row in li.conflictClasstime">
                          <td align="center">{{row.teacherUserName}}</td>
                          <td align="center" style="color: red;">{{row.classroomName}}</td>
                          <td align="center">{{row.className}}</td>
                          <td align="center">{{row.courseName}}</td>
                          <td align="center">
                            {{row.startTime.split(" ")[0]}}
                            &nbsp;
                            {{li.curClasstime.week}}
                            &nbsp;
                            {{row.startTime.split(" ")[1]}}-{{row.endTime.split(" ")[1]}}
                          </td>
                          <td align="center">第{{row.orderBy}}次课</td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </el-collapse-transition>
              </span>
            </span>
          </div>
        </div>

        <div class="Btn-box">
          <div class="info" @click="preStep">上一步</div>
          <div style="width:0.2rem;"></div>
          <div class="success" @click="saveOk">确认排课</div>
        </div>
      </div>
    </el-dialog>

    <!--快速保存排课按钮-->
    <!-- <div  class="quickSave" @click="SaveCourseSchedule" v-if="classInfo"></div> -->
    <!-- 固定头部 -->
    <div id="box-staticHead"></div>

    <!--双师引导图-->

    <el-dialog
	  id="shuangshi"
      v-if="classInfo"
      :visible.sync="guideShow"
      :close-on-click-modal="modalclose"
      custom-class="double-teacher-dialog"
    >
      <div class="double-teacher-guide">
        <div class="Process">
          <div class="step-box">
            <div class="circle circle-active">1</div>
            <div class="circle-title circle-title-active">排课</div>
          </div>
          <div class="line">------------------------------</div>
          <div class="step-box">
            <div class="circle">2</div>
            <div class="circle-title">约名师</div>
          </div>
          <div class="line">------------------------------</div>
          <div class="step-box">
            <div class="circle">3</div>
            <div class="circle-title">支付宝</div>
          </div>
          <div class="line">------------------------------</div>
          <div class="step-box">
            <div class="circle">4</div>
            <div class="circle-title">排课成功</div>
          </div>
        </div>
        <div class="btn-box">
          <div
            class="returnClass"
            @click="returnclassManage"
            v-if="classInfo.classOrTrialClass==1"
          >返回班级管理</div>
          <div
            class="returnClass"
            @click="returnclassManage"
            v-else-if="classInfo.classOrTrialClass==2"
          >返回试听管理</div>&nbsp;
          <div class="next-step" @click="showOrderForeignSyllabuslist()">下一步</div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import syllabusCalendar from "./newsyllabusCalendar"; //课程表
import { mapState, mapGetters, mapActions } from "vuex"; //先要引入
let vm;
export default {
  components: {
    syllabusCalendar
  },
  data() {
    return {
      isShow: false,
      modalclose: false,
      classInfo: null,
      quicksave: null, //保存对象
      guideShow: false,
      coursetypeObj: {}, //课程类型数据字典对象
      //排课面板
      newcalendar: {
        isShow: false,
        editor: true,
        isClose: false,
        schedulingTimes: 0,
        syllabusList: null,
        tempschedulinglist: [], //临时保存待排课列表
        weeks: [
          { name: "星期一", value: "1" },
          { name: "星期二", value: "2" },
          { name: "星期三", value: "3" },
          { name: "星期四", value: "4" },
          { name: "星期五", value: "5" },
          { name: "星期六", value: "6" },
          { name: "星期日", value: "0" }
        ],
        teacher: [],
        asssister: [],
        classroom: []
      },
      //排课日历
      param: {
        course: "", //用于搜索
        teacher: "", //用于搜索
        assister: "", //用于搜索
        classroom: "", //用于搜索
        repeatType: "", //重复频率
        holidayradio: "", //避免节假日周末
        radio: "1", //重复周期
        startDate: "", //课表开始日期 默认班级开班时间
        endDate: "", //课表结束日期 默认班级结束时间
        classInfo: null, //为了防止双向传递
        currentTime: "2019-04-02", //当前显示时间
        /**数据加载等待 */
        dataloading: false,
        curDate: "", //当期日期
        week: "", //当期周
        classtext: "", //班级id
        assistertext: "", //助教id
        teachertext: "", //教师id
        classroomtext: "", //教室id
        coursetext: "", //课程id
        courseName: "", //课程名称
        childCourseId: "", //全日制子课程id
        dayStartTime: "", //一天的开始时间
        dayEndTime: "", //一天的结束时间
        isTrialClass: 0, //是否是试听课
        classOrTrialClass: 1 //1.正常课 2.试听课
      },
      conflict: {
        isShow: false,
        syllabusList: []
      },
      //临时数组便于搜索
      tempcourselist: [],
      tempteacherlist: [],
      tempassistlist: [],
      tempclassroomlist: [],
      courselist: [],
      teacherlist: [],
      assistlist: [],
      classroomlist: []
    };
  },
  methods: {
    init(initdata) {
      //debugger

      let dicdata = tool.getItem(lsKey.dict, true);
      let coursetype = dicdata["course_type"]; //班级状态数据字典
      for (let i = 0; i < coursetype.length; i++) {
        this.coursetypeObj[coursetype[i]["value"]] = coursetype[i]["name"];
      }

      // if(vm.quicksave!=null){	//快速保存按钮样式
      // 	vm.quicksave.removeClass("quickSaveHide").addClass("quickSaveShow");
      // }

      vm.isShow = true;
      vm.classInfo = initdata;

      if (vm.classInfo.classOrTrialClass == 2) {
        //试听课去掉日期后面的时间
        vm.param.radio = "0"; //默认是不重复排课
        vm.classInfo.endTime = vm.classInfo.endTime.split(" ")[0];
        vm.classInfo.startTime = vm.classInfo.startTime.split(" ")[0];
      }
      // debugger
      //为了防止双向传递
      vm.param.classInfo = {
        className: vm.classInfo.className,
        courseName: vm.classInfo.courseName,
        subjectName: vm.classInfo.subjectName,
        courseTypeName: vm.classInfo.courseTypeName,
        courseMode: vm.classInfo.courseMode,
        oneCourseHour: vm.classInfo.oneCourseHour,
        oneCourseHourMinute: vm.classInfo.oneCourseHourMinute,
        startTime: vm.classInfo.startTime,
        endTime: vm.classInfo.endTime,
        teacherUserName: vm.classInfo.teacherUserName,
        assisUserName: vm.classInfo.assisUserName,
        classRoomName: vm.classInfo.classRoomName,
        classId: vm.classInfo.classId,
        courseTypeId: vm.classInfo.courseType,
        courseTimeMode: vm.classInfo.coursePackage
          ? vm.classInfo.coursePackage.courseTimeMode
          : "",
        classTypeMode: vm.classInfo.classTypeMode,
        classStatusMode: vm.classInfo.classStatusMode,
        coursePackageId: vm.classInfo.coursePackageId,
        totalCourseHour: vm.classInfo.totalCourseHour,
        dayStartTime: vm.classInfo.dayStartTime || "08:00",
        dayEndTime: vm.classInfo.dayEndTime || "21:00",
        assisUserId: vm.classInfo.assisUserId,
        teacherUserId: vm.classInfo.teacherUserId,
        classRoomId: vm.classInfo.classRoomId,
        courseId: vm.classInfo.courseId || vm.classInfo.coursePackage.courseId,
        isTrialClass: 1, //是否是包括试听课 0：不是 1：是
        isReadjust: vm.classInfo.isReadjust, //是否重排 0:不重排, 1:重排
        classOrTrialClass: vm.classInfo.classOrTrialClass
      };
      //排课日历默认值

      vm.param.classtext = vm.param.classInfo.classId;
      vm.param.coursetext = vm.param.classInfo.courseId;
      vm.param.currentTime = vm.param.classInfo.startTime;
      vm.param.dayStartTime = vm.param.classInfo.dayStartTime || "08:00";
      vm.param.dayEndTime = vm.param.classInfo.dayEndTime || "21:00";
      vm.param.isTrialClass = vm.param.classInfo.isTrialClass;
      vm.param.classOrTrialClass = vm.param.classInfo.classOrTrialClass;
      let param = { campusId: vm.$store.state.campusId };
      this.$nextTick(() => {
        vm.isStaticVisible();
      });
      //获取教师助教信息

      api
        .userListByCampus(param)
        .then(function(data) {
          let list = data.userList;
          let templist = [];
          let templist2 = [];
          for (let i = 0; i < list.length; i++) {
            let tid = vm.classInfo.teacherUserId;
            let aid = vm.classInfo.assisUserId;
            //教师
            if (tid == list[i].userId) {
              //教师默认值
              vm.param.teachertext = list[i].userId;
              templist.unshift({
                name: list[i].nickName,
                check: true,
                styleclass: "yes-icon",
                Id: list[i].userId
              });
            } else {
              templist.push({
                name: list[i].nickName,
                check: false,
                styleclass: "default-icon",
                Id: list[i].userId
              });
            }
            //助教
            if (aid == list[i].userId) {
              //助教默认
              vm.param.assistertext = list[i].userId;
              templist2.unshift({
                name: list[i].nickName,
                check: true,
                styleclass: "yes-icon",
                Id: list[i].userId
              });
            } else {
              templist2.push({
                name: list[i].nickName,
                check: false,
                styleclass: "default-icon",
                Id: list[i].userId
              });
            }
          }
          //给左面板、排课面板的教师、助教赋值
          vm.tempteacherlist = templist;
          vm.teacherlist = templist;
          vm.tempassistlist = templist2;
          vm.assistlist = templist2;
          vm.newcalendar.teacher = templist;
          vm.newcalendar.asssister = templist2;
          return api.getClassroomList(param);
        })
        .then(function(data) {
          //获取教室信息

          let list = data.info;
          let templist = [];
          for (let i = 0; i < list.length; i++) {
            let id = vm.classInfo.classRoomId;
            if (id == list[i].classroomId) {
              //教室默认值
              vm.param.classroomtext = list[i].classroomId;
              templist.unshift({
                name: list[i].name,
                check: true,
                styleclass: "yes-icon",
                Id: list[i].classroomId
              });
            } else {
              templist.push({
                name: list[i].name,
                check: false,
                styleclass: "default-icon",
                Id: list[i].classroomId
              });
            }
          }
          vm.tempclassroomlist = templist;
          vm.classroomlist = templist;
          vm.newcalendar.classroom = templist;

          return api.getLibraryCourseListOfCourse({
            courseId: vm.classInfo.courseId
          });
        })
        .then(function(data) {
          //获取课程信息
          //获取课程包信息
          //debugger
          let list = data.list;
          let templist = [];
          if (vm.param.classInfo.courseTypeId == "2") {
            //全日制班级处理
            let sMin = tool.hourConversionMin(vm.param.classInfo.dayStartTime);
            let eMin = tool.hourConversionMin(vm.param.classInfo.dayEndTime);
            let sumHour = Math.abs(eMin - sMin) / 60;
            vm.param.classInfo.SumHour = sumHour.toFixed(1);
            vm.param.coursetext = "";
            templist = list.map(function(row) {
              return {
                name: row.libraryCourseName,
                check: false,
                styleclass: "default-icon",
                Id: row.libraryCourseId,
                courseId: row.libraryCourseId,
                oneCourseHourMinute: row.perSyllabusDuration
              };
            });
            //默认选中第一个课程
            if (templist.length > 0) {
              templist[0].check = true;
              templist[0].styleclass = "yes-icon";
              vm.param.courseName = templist[0].name;
              vm.param.childCourseId = templist[0].Id;

              vm.param.classInfo.oneCourseHourMinute =
                templist[0].oneCourseHourMinute;
            }
          } else {
            if (list.length > 0) {
              let li = list[0];
              vm.param.courseName = li.libraryCourseName;
              vm.param.coursetext = li.libraryCourseId;
              templist.unshift({
                name: li.libraryCourseName,
                check: true,
                styleclass: "yes-icon",
                Id: li.libraryCourseId,
                courseId: li.libraryCourseId
              });
            }
          }
          vm.courselist = templist;
          vm.tempcourselist = templist;
          console.log(vm.param);
          vm.$refs.syllabusControl.init(); //初始化排课	//为了把教师、教室、助教信息传过去
          //						let list = data.list.map(function(row){
          //
          //							if(row.maxHourCoursePackage!=null){
          //								return {
          //							 		name:row.courseName,
          //							 		value:row.maxHourCoursePackage.coursePackageId,
          //							 		courseHour:row.maxHourCoursePackage.courseHour,
          //							 		subjectName:row.subjectName,
          //							 		courseTypeName:row.courseTypeName,
          //							 		courseMode:row.courseMode,
          //							 		courseId:row.courseId,
          //							 		courseTypeId:row.courseType,
          //							 		courseTimeMode:row.maxHourCoursePackage.courseTimeMode,
          //							 	}
          //							}else{
          //
          //								return [];
          //							}
          //					    })
          //					    let list = data.list;
          //						let templist = [];
          //						//普通班级
          //						for(let i =0;i<list.length;i++){
          //					      let id = vm.param.classInfo.coursePackageId;
          //					      if(id == list[i].value){//默认课程
          //					      	vm.param.courseName = list[i].name;
          //					      	vm.param.classInfo.courseTimeMode = list[i].courseTimeMode;
          //					      	vm.param.classInfo.courseTypeId =  list[i].courseTypeId
          //					      	templist.unshift({name:list[i].name,check:true,styleclass:'yes-icon',Id:list[i].value,courseId:list[i].courseId});
          //
          //					      }
          //				    	}
          //
          //
          //						if(vm.param.classInfo.courseTypeId=='2'){//全日制班级处理
          //							let sMin = tool.hourConversionMin(vm.param.classInfo.dayStartTime);
          //							let eMin = tool.hourConversionMin(vm.param.classInfo.dayEndTime);
          //							let sumHour = Math.abs(eMin-sMin)/60;
          //							vm.param.classInfo.SumHour = sumHour.toFixed(1);
          //							let para = {courseId:vm.param.classInfo.courseId};
          //
          //							api.getCourseListByPackageId(para).then(function(data){
          //								let list = data.list;
          //
          //								vm.param.coursetext="";
          //								templist = list.map(function(row){
          //
          //									return {name:row.courseItemName,check:false,styleclass:'default-icon',Id:row.courseItemId,courseId:row.courseItemId,oneCourseHourMinute:row.oneCourseHourMinute}
          //								})
          //								//默认选中第一个课程
          //								if(templist.length>0)
          //								{
          //
          //									templist[0].check = true;
          //									templist[0].styleclass = "yes-icon";
          //									vm.param.courseName = templist[0].name;
          //									vm.param.childCourseId = templist[0].Id;
          //									vm.param.classInfo.oneCourseHourMinute = templist[0].oneCourseHourMinute;
          //								}
          //
          //								vm.courselist = templist;
          //								vm.tempcourselist = templist;
          //							    vm.$refs.syllabusControl.init();//初始化排课	//为了把教师、教室、助教信息传过去
          //
          //							})
          //
          //							return;
          //						}
          //
          //
          //						vm.courselist = templist;
          //						vm.tempcourselist = templist;

          //  vm.$refs.syllabusControl.init();//初始化排课
        });
    },
    /**
     * type 选择类型 1.课程 2.教师3.助教4.教室5.重复频率
     * li 类型对象
     */
    changeCheck(type, li) {
      if (li.check == "success") return;

      if (type == 1) {
        //一次只能排一次课程的课
        let clist = vm.$store.state.courselist;
        if (clist.length > 0) {
          vm.$message({
            message: "请先排完本次课程",
            type: "warning"
          });
          return;
        }
      }

      let tempcheck = li.check;
      if (tempcheck) return; //选中后则不能取消，只能选其他的
      let tempId = li.Id;
      let tempList = [];
      li.check = tempcheck ? false : true;
      li.styleclass = tempcheck ? "default-icon" : "yes-icon";

      if (type == 1) {
        //课程列表

        vm.param.classInfo.oneCourseHourMinute = li.oneCourseHourMinute;
        tempList = vm.courselist;
        vm.param.childCourseId = li.courseId;
        vm.param.courseName = li.name;
      } else if (type == 2) {
        //教师列表
        vm.param.teachertext = tempId;
        vm.param.classInfo.teacherUserName = li.name;
        tempList = vm.teacherlist;
        vm.$refs.syllabusControl.updateClassTableByCondition();
      } else if (type == 3) {
        //助教列表
        vm.param.assistertext = tempId;
        vm.param.classInfo.assisUserName = li.name;
        tempList = vm.assistlist;
        vm.$refs.syllabusControl.updateClassTableByCondition();
      } else if (type == 4) {
        vm.param.classroomtext = tempId;
        vm.param.classInfo.classRoomName = li.name;
        tempList = vm.classroomlist;
        vm.$refs.syllabusControl.updateClassTableByCondition();
      }

      for (let i = 0; i < tempList.length; i++) {
        if (tempId != tempList[i].Id) {
          if (tempList[i].check && tempList[i].check != "success") {
            tempList[i].check = false;
            tempList[i].styleclass = "default-icon";
          }
        }
      }
    },
    /**
     * 双击已排课课程
     */
    reCheck(li) {
      if (li.check != "success") return;
      for (let i = 0; i < vm.tempcourselist.length; i++) {
        let course = vm.tempcourselist[i];
        if (li.Id == course.Id) {
          course.check = true;
          course.styleclass = "yes-icon";
          vm.param.childCourseId = course.Id;
          vm.param.courseName = course.name;
          vm.param.classInfo.oneCourseHourMinute = course.oneCourseHourMinute;
        } else {
          course.check = course.check == "success" ? course.check : false;
          course.styleclass =
            course.styleclass == "success-icon"
              ? course.styleclass
              : "default-icon";
        }
      }
    },
    /**
     * querystr 匹配字符串
     * 课程搜索
     */
    querycourseList(querystr) {
      vm.filterlist(1, querystr);
    },
    /**
     * querystr 匹配字符串
     * 教师搜索
     */
    queryteacherList(querystr) {
      vm.filterlist(2, querystr);
    },
    /**
     * querystr 匹配字符串
     * 助教搜索
     */
    queryasisterList(querystr) {
      vm.filterlist(3, querystr);
    },
    /**
     * querystr 匹配字符串
     * 教室搜索
     */
    queryclassroomList(querystr) {
      vm.filterlist(4, querystr);
    },
    /**
     * querystr 匹配字符串
     * 重复频率搜索
     */
    queryrepeatList(querystr) {
      vm.filterlist(5, querystr);
    },
    /**
     * type 选择类型 1.课程 2.教师3.助教4.教室5.重复频率
     * str 搜索匹配关键字
     */
    filterlist(type, str) {
      let all = false;
      if (str == "") all = true;
      let list = [];
      if (type == 1) {
        list = vm.courselist;
        vm.tempcourselist = list.filter((item, index, arr) =>
          all ? true : item.name.includes(str)
        );
      } else if (type == 2) {
        list = vm.teacherlist;
        vm.tempteacherlist = list.filter((item, index, arr) =>
          all ? true : item.name.includes(str)
        );
      } else if (type == 3) {
        list = vm.assistlist;
        vm.tempassistlist = list.filter((item, index, arr) =>
          all ? true : item.name.includes(str)
        );
      } else if (type == 4) {
        list = vm.classroomlist;
        vm.tempclassroomlist = list.filter((item, index, arr) =>
          all ? true : item.name.includes(str)
        );
      }
    },

    /**
     * 关闭排课日历
     */
    closeScheule(done) {
      vm.$store.commit("clearCourselist", []);

      vm.$boxStaticHead.css("display", "none");

      vm.$refs.syllabusControl.clearCourselist(); //初始化排课

      vm.param.course = ""; //用于搜索
      vm.param.teacher = ""; //用于搜索
      vm.param.assister = ""; //用于搜索
      vm.param.classroom = ""; //用于搜索
      vm.param.repeatType = "";
      vm.param.holidayradio = "";
      vm.param.radio = "1";
      vm.param.startDate = ""; //课表开始日期 默认班级开班时间
      vm.param.endDate = ""; //课表结束日期 默认班级结束时间
      vm.param.classtext = ""; //班级id
      vm.param.assistertext = ""; //助教id
      vm.param.teachertext = ""; //教师id
      vm.param.classroomtext = ""; //教室id
      vm.param.coursetext = ""; //课程id
      vm.param.courseName = ""; //课程名称
      vm.param.childCourseId = ""; //全日制子课程id
      vm.param.dayStartTime = ""; //一天的开始时间
      vm.param.dayEndTime = ""; //一天的结束时间
      //				if(vm.$parent.searchData){
      //					vm.$parent.searchData();//刷新班级列表
      //				}

      done();
    },
    /**
     * 显示隐藏排课面板
     */
    parentMethods(e) {
      if (e.event == "click") {
        //排课只能在班级开始时间与结课时间内容排课
        let stime = e.startTime;

        vm.param.curDate = e.curDate;
        vm.param.week = e.week;
        //一天上课开始时间-结束时间
        vm.setEndTime(vm.param.week);

        //排课只能在当前日期后台排

        let d = new Date();
        let curdate = tool.DateToString(d, "yyyy-MM-dd");
        // if (e.curDate < curdate) {
        //   vm.$message({
        //     message: e.curDate + "排课日期不符合条件",
        //     type: "warning"
        //   });
        //   return;
        // }
        //日历点击禁止设置在班级开班时间与结束时间
        if (
          e.curDate < vm.param.classInfo.startTime ||
          e.curDate > vm.param.classInfo.endTime
        ) {
          vm.$message({
            message:
              "请在" +
              vm.param.classInfo.startTime +
              "-" +
              vm.param.classInfo.endTime +
              "日期内进行排课",
            type: "warning"
          });
          return;
        }

        if (vm.param.teachertext == "") {
          vm.$message({
            message: "请选择教师",
            type: "warning"
          });
          return;
        } else if (vm.param.classroomtext == "") {
          vm.$message({
            message: "请选择教室",
            type: "warning"
          });
          return;
        } else if (vm.param.coursetext == "" && vm.param.childCourseId == "") {
          vm.$message({
            message: "请选择课程",
            type: "warning"
          });
          return;
        }

        let dsMin = tool.hourConversionMin(vm.param.classInfo.dayStartTime);
        let deMin = tool.hourConversionMin(vm.param.classInfo.dayEndTime);

        //单次课开始时间
        let Min = tool.hourConversionMin(e.startTime);
        if (Min < dsMin || Min > deMin) {
          vm.$message({
            message:
              "上课时间只能在" +
              vm.param.classInfo.dayStartTime +
              "-" +
              vm.param.classInfo.dayEndTime,
            type: "warning"
          });
          return;
        }
        //排课列表中新增课次默认使用
        let templist = vm.$store.state.courselist;
        templist = vm.ReSortList(templist);
        vm.newcalendar.tempschedulinglist = [];

        for (let i = 0; i < templist.length; i++) {
          templist[i].editor = false;
          templist[i].newItem = false;
          vm.newcalendar.tempschedulinglist.push(templist[i]);
        }

        if (vm.newcalendar.tempschedulinglist.length >= 10) {
          //每次排课不得大于10

          return;
        }

        if (vm.classInfo.classOrTrialClass == 2) {
          //试听班级
          vm.newcalendar.tempschedulinglist = [];
        }

        if (
          vm.param.classInfo.courseTypeId == "3" ||
          vm.param.classInfo.courseTypeId == "5" ||
          vm.param.classInfo.courseTypeId == "4"
        ) {
          //普通班  一对一 双师

          let totalmin;
          if (vm.param.classInfo.courseTypeId == 4) {
            totalmin =
              vm.param.classInfo.oneCourseHour *
              vm.param.classInfo.oneCourseHourMinute;
          } else {
            totalmin =
              vm.param.classInfo.oneCourseHour *
              vm.param.classInfo.oneCourseHourMinute;
          }
          //alert(totalmin)
          let eTime = tool.calculEndTime(e.startTime, totalmin);

          if (eTime > vm.param.classInfo.dayEndTime) {
            vm.$message({
              message: "结课时间" + eTime + "超过校区设置时间",
              type: "warning"
            });
            return;
          }

          vm.newcalendar.tempschedulinglist.push({
            uuid: tool.uuid(),
            index: vm.newcalendar.tempschedulinglist.length + 1,
            tempweek: e.week,
            week: e.week,
            curDate: e.curDate,
            starttime: e.startTime,
            tempstarttime: e.startTime, //为了保存当前开始时间，为了计算结束时间
            tempendTime: eTime,
            endTime: eTime,
            classhour: vm.classInfo.oneCourseHour,
            teacher: vm.param.teachertext,
            assister: vm.param.assistertext,
            classroom: vm.param.classroomtext,
            teacherUserName: vm.param.classInfo.teacherUserName,
            classRoomName: vm.param.classInfo.classRoomName,
            courseName: vm.param.courseName,
            courseId: vm.param.coursetext,
            editor: false, //是否在编辑
            newItem: true //是否是新增
          });
        } else if (vm.param.classInfo.courseTypeId == "2") {
          //全日制班

          let eTime = tool.calculEndTime(
            e.startTime,
            vm.param.classInfo.oneCourseHourMinute
          );

          if (eTime > vm.param.classInfo.dayEndTime) {
            vm.$message({
              message: "结课时间已超过校区设置时间",
              type: "warning"
            });
            return;
          }
          let etime = tool.calculEndTime(
            e.startTime,
            vm.param.classInfo.oneCourseHourMinute
          );
          vm.newcalendar.tempschedulinglist.push({
            uuid: tool.uuid(),
            index: vm.newcalendar.tempschedulinglist.length + 1,
            tempweek: e.week,
            week: e.week,
            curDate: e.curDate,
            tempstarttime: e.startTime, //为了保存当前开始时间，为了计算结束时间
            starttime: e.startTime,
            tempendTime: etime,
            endTime: etime,
            classhour: vm.param.classInfo.oneCourseHourMinute,
            teacher: vm.param.teachertext,
            assister: vm.param.assistertext,
            classroom: vm.param.classroomtext,
            teacherUserName: vm.param.classInfo.teacherUserName,
            classRoomName: vm.param.classInfo.classRoomName,
            courseName: vm.param.courseName,
            courseId: vm.param.childCourseId,
            editor: false,
            newItem: true //是否是新增
          });
        }

        vm.newcalendar.schedulingTimes =
          vm.newcalendar.tempschedulinglist.length;
        vm.newcalendar.isShow = true;
      } else if (e.event == "editor") {
        //编辑未保存排课列表

        vm.newcalendar.tempschedulinglist = [];
        let templist = vm.$store.state.courselist;
        templist = vm.ReSortList(templist);
        vm.newcalendar.tempschedulinglist = templist;
        for (let i = 0; i < templist.length; i++) {
          if (templist[i].uuid == e.uuid) {
            templist[i].editor = true;
          } else {
            templist[i].editor = false;
          }
          templist[i].newItem = false;
        }
        vm.newcalendar.schedulingTimes =
          vm.newcalendar.tempschedulinglist.length;
        vm.newcalendar.isShow = true;
      } else if (e.event == "editored") {
        //编辑已排课课程

        let classtimes = e.courseObj;
        vm.newcalendar.tempschedulinglist = [];
        vm.newcalendar.tempschedulinglist.push({
          uuid: "已排课",
          index: classtimes.orderBy,
          tempweek: e.week,
          week: e.week,
          curDate: e.curDate,
          tempstarttime: classtimes.startTime.split(" ")[1], //为了保存当前开始时间，为了计算结束时间
          starttime: classtimes.startTime.split(" ")[1],
          tempendTime: classtimes.endTime.split(" ")[1],
          endTime: classtimes.endTime.split(" ")[1],
          classhour: 1,
          teacher: vm.param.teachertext,
          assister: vm.param.assistertext,
          classroom: vm.param.classroomtext,
          teacherUserName: vm.param.classInfo.teacherUserName,
          classRoomName: vm.param.classInfo.classRoomName,
          courseName: vm.param.courseName,
          courseId: vm.param.childCourseId,
          editor: false
        });
        console.log("AAAAAAAAAAAAAAAAAA", vm.newcalendar.tempschedulinglist);
      } else if (e.event == "save") {
        //保存排课
        vm.SaveCourseSchedule();
      } else if (e.event == "resettime") {
        this.$nextTick(() => {
          vm.addTopStaticDate();
        });
      }
    },
    /**
     * 排课面板确定按钮
     */
    schedulingOk() {
      console.log("AAAAAAAAAAAAAAA", vm.newcalendar.tempschedulinglist);
      let _result = vm.checkTime(vm.newcalendar.tempschedulinglist);

      if (!_result.result) {
        vm.$message({
          message:
            "第" +
            (_result.j + 1) +
            "次课和第" +
            (_result.i + 1) +
            "次课" +
            "上课时间有冲突,请核查",
          type: "warning"
        });
        return;
      }
      let $teacher = vm.$refs.teacher;
      let $classroom = vm.$refs.classroom;
      let rules = [];

      for (let i = 0; i < $teacher.length; i++) {
        if ($teacher[i].value == "") {
          rules.push({
            judge: null,
            focus: $teacher[i],
            tips: "教师不能为空"
          });
        }

        if ($classroom[i].value == "") {
          rules.push({
            judge: null,
            focus: $classroom[i],
            tips: "教室不能为空"
          });
        }
      }

      if (!tool.validate(rules)) {
        return;
      }
      vm.newcalendar.isShow = false;
      console.log("AAAAAAAAAAAAAAA", vm.newcalendar.tempschedulinglist);
      vm.$store.commit("setCourselist", vm.newcalendar.tempschedulinglist);
      vm.$refs.syllabusControl.updateClassTableByCondition();
    },
    /**
     * 排课面板取消按钮
     */
    schedulingCancel() {
      vm.newcalendar.isShow = false;
    },
    /**
     * 开始时间选择
     */
    selectStartTime(li) {
      //一天上课开始时间-结束时间
      // debugger
      vm.setEndTime(li.week);
      let totalmin =
        vm.param.classInfo.oneCourseHour *
        vm.param.classInfo.oneCourseHourMinute;
      //  alert(vm.param.classInfo.oneCourseHour)
      let eTime = tool.calculEndTime(
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime,
        totalmin
      );

      if (eTime > vm.param.classInfo.dayEndTime) {
        vm.$message({
          message: "结课时间" + eTime + "不合理",
          type: "warning"
        });
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime =
          vm.newcalendar.tempschedulinglist[li.index - 1].tempstarttime;
        vm.newcalendar.tempschedulinglist[li.index - 1].endTime =
          vm.newcalendar.tempschedulinglist[li.index - 1].tempendTime;
        return;
      }
      vm.newcalendar.tempschedulinglist[li.index - 1].endTime = eTime;
      vm.newcalendar.tempschedulinglist[li.index - 1].tempendTime = eTime;
      vm.newcalendar.tempschedulinglist[li.index - 1].tempstarttime =
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime;
    },
    /**
     * 选择全日制开始时间
     */
    selectAllStartTime(li) {
      //一天上课开始时间-结束时间

      vm.setEndTime(li.week);
      let totalmin = vm.param.classInfo.oneCourseHourMinute;

      let eTime = tool.calculEndTime(
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime,
        totalmin
      );
      if (eTime > vm.param.classInfo.dayEndTime) {
        vm.$message({
          message: "结课时间" + eTime + "不合理",
          type: "warning"
        });
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime =
          vm.newcalendar.tempschedulinglist[li.index - 1].tempstarttime;
        vm.newcalendar.tempschedulinglist[li.index - 1].endTime =
          vm.newcalendar.tempschedulinglist[li.index - 1].tempendTime;
        return;
      }
      vm.newcalendar.tempschedulinglist[li.index - 1].endTime = eTime;
      vm.newcalendar.tempschedulinglist[li.index - 1].tempendTime = eTime;
      vm.newcalendar.tempschedulinglist[li.index - 1].tempstarttime =
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime;
      //如果是第一行做更改，那其他行跟着改
      if (li.index == 1) {
        for (let i = 0; i < vm.newcalendar.tempschedulinglist.length; i++) {
          let temp = vm.newcalendar.tempschedulinglist[i];
          temp.starttime = li.starttime;
          temp.endTime = eTime;
        }
      }
    },

    /**
     * 改变排课次数
     */
    changetimes(value) {
      let len = vm.newcalendar.tempschedulinglist.length;
      let num = value - len;

      if (num >= 0) {
        //增加课次

        for (let i = 0; i < num; i++) {
          let stime =
            vm.newcalendar.tempschedulinglist.length <= 0
              ? "08:00"
              : vm.newcalendar.tempschedulinglist[0].starttime;
          let totalmin;

          let one = vm.param.classInfo.oneCourseHour || 1;
          if (vm.param.classInfo.courseTypeId == 4) {
            totalmin = one * vm.param.classInfo.oneCourseHourMinute;
          } else {
            totalmin = one * vm.param.classInfo.oneCourseHourMinute;
          }
          let eTime = tool.calculEndTime(stime, totalmin);

          if (eTime > vm.param.classInfo.dayEndTime) {
            vm.$message({
              message: "结课时间" + eTime + "不合理",
              type: "warning"
            });
            return;
          }
          let courseid =
            vm.param.classInfo.courseTypeId == "2"
              ? vm.param.childCourseId
              : vm.param.coursetext;

          vm.newcalendar.tempschedulinglist.push({
            uuid: tool.uuid(),
            index: ++len,
            week: vm.param.week,
            tempweek: vm.param.week,
            curDate: vm.param.curDate,
            starttime: stime,
            tempstarttime: stime,
            endTime: eTime,
            classhour: vm.classInfo.oneCourseHour || 1,
            teacher: vm.param.teachertext,
            assister: vm.param.assistertext,
            classroom: vm.param.classroomtext,
            teacherUserName: vm.param.classInfo.teacherUserName,
            classRoomName: vm.param.classInfo.classRoomName,
            courseName: vm.param.courseName,
            courseId: courseid,
            editor: false,
            newItem: true
          });
        }
        console.log("AAAAAAAAAAAAAAA", vm.newcalendar.tempschedulinglist);
      } else {
        //减少课次
        num = Math.abs(num);
        vm.newcalendar.tempschedulinglist.splice(value, num);
      }
    },
    /**
     *
     */
    selectWeek(li) {
      //一天上课开始时间-结束时间
      console.log("AAAAAAAAAAAAAAA", vm.newcalendar.tempschedulinglist);
      vm.setEndTime(li.week);
      let num = vm.param.classInfo.oneCourseHour || 1;
      let eTime = tool.calculEndTime(
        vm.newcalendar.tempschedulinglist[li.index - 1].starttime,
        num * vm.param.classInfo.oneCourseHourMinute
      );
      if (eTime > vm.param.classInfo.dayEndTime) {
        vm.$message({
          message: "结课时间" + eTime + "不合理",
          type: "warning"
        });
        vm.newcalendar.tempschedulinglist[li.index - 1].week =
          vm.newcalendar.tempschedulinglist[li.index - 1].tempweek;

        return;
      }
      vm.newcalendar.tempschedulinglist[li.index - 1].endTime = eTime;
      vm.newcalendar.tempschedulinglist[li.index - 1].tempendTime = eTime;
      vm.newcalendar.tempschedulinglist[li.index - 1].tempweek =
        vm.newcalendar.tempschedulinglist[li.index - 1].week;
      // debugger;
      let curdate = new Date(li.curDate);
      let curday = curdate.getDay(); //原本天
      let liday = Number(li.week); //选择天
      if (liday == 0) liday = 7;
      curdate.setDate(curdate.getDate() + (liday - curday));

      let newdate = tool.DateToString(curdate, "yyyy-MM-dd");
      // console.log("AAAAAAAAAAAAAAA",newdate);
      vm.newcalendar.tempschedulinglist[li.index - 1].week = li.week;
      vm.newcalendar.tempschedulinglist[li.index - 1].curDate = newdate;
      // console.log("AAAAAAAAAAAAAAA",vm.newcalendar.tempschedulinglist);
    },
    /**
     * 设置结课时间
     */
    setEndTime(week) {
      if (config.weekTimeList.length <= 0) {
        vm.param.classInfo.dayStartTime = "07:00";
        vm.param.classInfo.dayEndTime = "21:00";
      } else {
        for (let i = 0; i < config.weekTimeList.length; i++) {
          if (week == config.weekTimeList[i].weekMode) {
            vm.param.classInfo.dayStartTime = config.weekTimeList[i].startTime;
            vm.param.classInfo.dayEndTime = config.weekTimeList[i].endTime;
          }
        }
        if (
          vm.param.classInfo.dayStartTime == "" ||
          vm.param.classInfo.dayStartTime == ""
        ) {
          vm.param.classInfo.dayStartTime = config.weekTimeList[0].startTime;
          vm.param.classInfo.dayEndTime = config.weekTimeList[0].endTime;
        }
      }

      if (
        vm.param.classInfo.dayStartTime == "" ||
        vm.param.classInfo.dayStartTime == ""
      ) {
        vm.$message({
          message: "请先设置上课时间",
          type: "warning"
        });
        return;
      }
    },
    /**
     * 选择
     */
    changeLi(type, li) {
      if (type == 1) {
        //教师

        for (let i = 0; i < vm.newcalendar.tempschedulinglist.length; i++) {
          let teacher = vm.newcalendar.tempschedulinglist[i];
          if (teacher.teacher == "") {
            teacher.teacher = li.teacher;
            teacher.teacherUserName = li.teacherUserName;
          } else {
            for (let j = 0; j < vm.newcalendar.teacher.length; j++) {
              let tempteacher = vm.newcalendar.teacher[j];
              if (tempteacher.Id == teacher.teacher) {
                teacher.teacherUserName = tempteacher.name;
              }
            }
          }
        }
      } else if (type == 2) {
        //助教

        for (let i = 0; i < vm.newcalendar.tempschedulinglist.length; i++) {
          let assister = vm.newcalendar.tempschedulinglist[i];
          if (assister.assister == "") {
            assister.assister = li.assister;
          }
        }
      } else if (type == 3) {
        //教室

        for (let i = 0; i < vm.newcalendar.tempschedulinglist.length; i++) {
          let classroom = vm.newcalendar.tempschedulinglist[i];
          if (classroom.classroom == "") {
            classroom.classroom = li.classroom;
          } else {
            for (let j = 0; j < vm.newcalendar.classroom.length; j++) {
              let tempclassroom = vm.newcalendar.classroom[j];
              if (tempclassroom.Id == classroom.classroom) {
                classroom.classRoomName = tempclassroom.name;
              }
            }
          }
        }
      }
    },
    /**
     * 选择避开排课日期方式
     */
    selectType(val) {
      if (val == 1) {
        //避开周末
        vm.newcalendar.weeks = [
          { name: "星期一", value: "1" },
          { name: "星期二", value: "2" },
          { name: "星期三", value: "3" },
          { name: "星期四", value: "4" },
          { name: "星期五", value: "5" }
        ];
      } else if (val == 2) {
        //避开节假日

        vm.newcalendar.weeks = [
          { name: "星期一", value: "1" },
          { name: "星期二", value: "2" },
          { name: "星期三", value: "3" },
          { name: "星期四", value: "4" },
          { name: "星期五", value: "5" },
          { name: "星期六", value: "6" },
          { name: "星期日", value: "0" }
        ];
      }
    },
    /**
     * 删除某次待排课程
     */
    delele(li) {
      for (let i = 0; i < vm.newcalendar.tempschedulinglist.length; i++) {
        let liindex = vm.newcalendar.tempschedulinglist[i];
        if (li.index == liindex.index) {
          vm.newcalendar.tempschedulinglist.splice(i, 1);
        }
      }
      vm.newcalendar.schedulingTimes = vm.newcalendar.tempschedulinglist.length;
    },
    /**
     * 课次列表重新排序
     */
    ReSortList(list) {
      //将课次周序号全部数字化，并将周日设为7
      for (let i = 0; i < list.length; i++) {
        list[i]["week"] = Number(list[i]["week"]);
        if (list[i]["week"] == 0) list[i]["week"] = 7;
      }
      //按周序号升序排序
      let templist = list.sort(function(x, y) {
        return x.week > y.week ? 1 : -1;
      });
      //console.log(templist)

      //按时间排序
      let returnlist = templist.sort(function(x, y) {
        if (x.week == y.week) {
          return x.starttime > y.starttime ? 1 : -1;
        }
      });

      for (let i = 0; i < returnlist.length; i++) {
        returnlist[i]["week"] = returnlist[i]["week"] + "";
        returnlist[i]["index"] = i + 1;
        if (returnlist[i]["week"] == "7") returnlist[i]["week"] = "0";
      }
      // console.log(templist)
      return returnlist;
    },
    /**
     * 时间检验
     */
    checkTime(timelist) {
      let _result = { result: true, i: 0, j: 0 };
      for (let i = 0; i < timelist.length; i++) {
        for (let j = 0; j < timelist.length; j++) {
          if (i != j) {
            if (timelist[i].week == timelist[j].week) {
              let min_1 = tool.hourConversionMin(timelist[i].starttime);
              let min_2 = tool.hourConversionMin(timelist[j].starttime);
              let minspan_1 =
                vm.classInfo.oneCourseHour * vm.classInfo.oneCourseHourMinute; //每次课总分钟
              let minspan_2 = Math.abs(min_1 - min_2); //两次课开始上课相差分钟数
              if (minspan_2 < minspan_1) {
                _result.result = false;
                _result.i = i;
                _result.j = j;
                break;
              }
            }
          }
        }
      }

      return _result;
    },
    /**
     *  冲突列表上一步
     */
    preStep() {
      vm.conflict.isShow = false;
    },
    /**
     * 确定排课
     */
    saveOk() {
      if (vm.newcalendar.syllabusList != null) {
        vm.newcalendar.syllabusList.isCheckConflict = 1;
        api.coursescheduling(vm.newcalendar.syllabusList).then(function(data) {
          vm.$store.commit("clearCourselist", []);
          vm.$refs.syllabusControl.updateClassTableByCondition();
          vm.refreshCourseStatus();
          vm.conflict.isShow = false;
          vm.$message({
            message: vm.newcalendar.syllabusList.courseName + "排课成功",
            type: "success"
          });
          if (vm.$parent.menu == 1) {
            vm.$parent.searchData(1); //刷新父组件
          } else {
            vm.$parent.selectOverClassData(1);
          }
          //判断是否是双师课
          if (vm.param.classInfo.courseTypeId == 4) {
            vm.isShow = false;
            vm.guideShow = true;
            vm.$boxStaticHead.css("display", "none");
            //    if(vm.quicksave==null){
            // 	vm.quicksave = $(".quickSave");
            // 	}
            // 	vm.quicksave.removeClass("quickSaveShow").addClass("quickSaveHide");
            //$(".mask").css("display","block")
          }
        });
      }
    },
    /**
     * 取消排课
     */
    saveCancel() {
      vm.$store.commit("clearCourselist", []);

      vm.$boxStaticHead.css("display", "none");

      vm.$refs.syllabusControl.clearCourselist(); //初始化排课

      vm.param.course = ""; //用于搜索
      vm.param.teacher = ""; //用于搜索
      vm.param.assister = ""; //用于搜索
      vm.param.classroom = ""; //用于搜索
      vm.param.repeatType = "";
      vm.param.holidayradio = "";
      vm.param.radio = "1";
      vm.param.startDate = ""; //课表开始日期 默认班级开班时间
      vm.param.endDate = ""; //课表结束日期 默认班级结束时间
      vm.param.classtext = ""; //班级id
      vm.param.assistertext = ""; //助教id
      vm.param.teachertext = ""; //教师id
      vm.param.classroomtext = ""; //教室id
      vm.param.coursetext = ""; //课程id
      vm.param.courseName = ""; //课程名称
      vm.param.childCourseId = ""; //全日制子课程id
      vm.param.dayStartTime = ""; //一天的开始时间
      vm.param.dayEndTime = ""; //一天的结束时间
      vm.isShow = false;
      // if(vm.$parent.searchData){
      // 	vm.$parent.searchData();//刷新班级列表
      // }
    },
    /**
     * 保存排课
     */
    SaveCourseSchedule() {
      //准备数据
      let data = [];
      vm.newcalendar.syllabusList = null;
      vm.newcalendar.syllabusList = {
        classId: vm.param.classInfo.classId,
        courseType: vm.param.classInfo.courseTypeId,
        classStartTime: vm.param.classInfo.startTime,
        classEndTime: vm.param.classInfo.endTime,
        weekCourseCount: 0,
        courseName: vm.param.courseName,
        coursePackageId: vm.param.classInfo.coursePackageId,
        repeatType: vm.param.radio,
        isCheckConflict: 0, //默认检查冲突
        ignoreDateType: "1", //是否避免节假日 1周末 2节假日
        timeTableStartTime: vm.param.startDate || vm.classInfo.startTime,
        timeTableEndTime: vm.param.endDate || vm.classInfo.endTime,
        isTrialClass: vm.param.classInfo.classOrTrialClass, //是否是试听课 1：不是 2：是
        isReadjust: vm.param.classInfo.isReadjust, //是否重排  0:不重排    1:重排
        classSyllabusWeekFormEntityList: []
      };

      let templist = vm.$store.state.courselist;
      if (templist.length <= 0) {
        vm.$message({
          message: "请选择排课时间",
          type: "warning"
        });
        return;
      }
      // console.log("AAAAAAAAAAAAAAA",templist);
      let itemlist = templist.map(function(row) {
        return {
          weekMode: row.week,
          startTime: row.curDate + " " + row.starttime,
          endTime: row.curDate + " " + row.endTime,
          courseHour: row.classhour,
          teacherUserId: row.teacher,
          assisUserId: row.assister,
          classroomId: row.classroom || "1234",
          totalHour: vm.param.classInfo.totalCourseHour || vm.totalDay,
          courseId: row.courseId,
          attendMode: 2
        };
      });
      vm.newcalendar.syllabusList._wait = "请稍后";
      vm.newcalendar.syllabusList.weekCourseCount = itemlist.length;
      vm.newcalendar.syllabusList.classSyllabusWeekFormEntityList = itemlist;

      //排课
      api.coursescheduling(vm.newcalendar.syllabusList).then(function(data) {
        if (data.result == "排课有冲突") {
          vm.conflict.isShow = true;
          vm.conflict.syllabusList = [];
          for (let i = 0; i < data.syllabusList.length; i++) {
            let li = data.syllabusList[i];
            let tempobj = {
              curClasstime: null,
              conflictClasstime: []
            };
            for (let j = 0; j < li.length; j++) {
              if (j == 0) {
                //原班课次
                let weekDate = li[j].startTime.split(" ")[0];
                let newdate = new Date(weekDate);
                li[j].week = tool.getWeek(weekDate);
                li[j].show = false;
                tempobj.curClasstime = li[j];
              } else {
                //冲突课次
                tempobj.conflictClasstime.push(li[j]);
              }
            }

            vm.conflict.syllabusList.push(tempobj);
          }
        } else if (data.result == "当前选项没有匹配课程表") {
          //排今天过去的时间
          vm.$message({
            message: "当前选择的时间没有可排的课表或者已排满",
            type: "warning"
          });
        } else {
          vm.$store.commit("clearCourselist", []);
          vm.refreshCourseStatus();
          vm.$refs.syllabusControl.updateClassTableByCondition(); //初始化排课	//为了把教师、教室、助教信息传过去

          if (vm.$parent.menu == 1) {
            vm.$parent.searchData(1); //刷新父组件
          } else {
            vm.$parent.selectOverClassData(1);
          }
          vm.$message({
            message: vm.newcalendar.syllabusList.courseName + "排课成功",
            type: "success"
          });
          //判断是否是双师课
          if (vm.param.classInfo.courseTypeId == 4) {
            vm.isShow = false;
            vm.guideShow = true;
            vm.$boxStaticHead.css("display", "none");
            //    if(vm.quicksave==null){
            // 		vm.quicksave = $(".quickSave");
            // 	}
            // 	vm.quicksave.removeClass("quickSaveShow").addClass("quickSaveHide");
          }
        }
      });
    },
    /**
     * 展开冲突详情详情
     */
    checkDetail(li) {
      li.curClasstime.show = li.curClasstime.show ? false : true;
    },
    /**
     * 刷新全日制左边列表课程状态
     */
    refreshCourseStatus() {
      if (vm.param.classInfo.courseTypeId == "2") {
        for (let i = 0; i < vm.tempcourselist.length; i++) {
          let li = vm.tempcourselist[i];
          if (li.Id == vm.param.childCourseId) {
            li.styleclass = "success-icon";
            li.check = "success";
            if (i >= vm.tempcourselist.length - 1) {
              return;
            } else {
              vm.tempcourselist[i + 1].styleclass = "yes-icon";
              vm.tempcourselist[i + 1].check = true;
              vm.param.classInfo.oneCourseHourMinute =
                vm.tempcourselist[i + 1].oneCourseHourMinute;
              vm.param.courseName = vm.tempcourselist[i + 1].name;
              vm.param.childCourseId = vm.tempcourselist[i + 1].courseId;
            }
            break;
          }
        }
      }
    },
    /**
     * 约外教
     */
    showOrderForeignSyllabuslist() {
      //关闭弹窗
      vm.guideShow = false;

      //试听班级
      if (vm.classInfo.isTrialClass == 1) {
        vm.$emit("callback", vm.classInfo.classId);
        return;
      }

      let param = {
        classId: vm.classInfo.classId,
        courseId: vm.classInfo.coursePackageId,
        unappointedSyllabus: 1
      };
      api.courseschedulinglist(param).then(function(data) {
        //排课列表
        if (data.listSyllabus.length > 0) {
          //已有排课
          let coursedata = {
            teacher: {
              visible: true,
              data: { classObj: vm.classInfo, courseObj: data.listSyllabus }
            },
            syllabus: { visible: false },
            classorder: { visible: false }
          };
          vm.$emit("callback", coursedata);
        }
      });
    },
    /**返回班级管理**/
    returnclassManage() {
      vm.guideShow = false;
    },

    isStaticVisible() {
      let scroll = document.getElementById("scroll");
      let rem = screen.width / 19.2;
      let sheight = Number(scroll.scrollTop);
      let h = sheight / rem;
      if (h <= 2.65) {
        vm.$boxStaticHead.css("display", "none");
      } else {
        vm.$boxStaticHead.css("display", "block");
      }
    },
    addTopStaticDate() {
      vm.$boxStaticHead.html("");
	  vm.$boxStaticHead.css('z-index',$('#scroll').css('z-index'));
      vm.staticHeadDate = $(".schedule-course .title_StudentManage.el-row").clone(true);
      vm.staticHeadDate.find(".toprow .el-icon-arrow-left.btn").click(() => {
        vm.$refs.syllabusControl.changeClassTime(-1);
        vm.$nextTick(() => {
          vm.addTopStaticDate();
        });
      });
      vm.staticHeadDate.find(".toprow .el-icon-arrow-right.btn").click(() => {
        vm.$refs.syllabusControl.changeClassTime(1);
        vm.$nextTick(() => {
          vm.addTopStaticDate();
        });
      });
      vm.$boxStaticHead.append(vm.staticHeadDate);

      vm.staticHeadWeek = $(".schedule-course .el-table__header-wrapper").clone(true);
      vm.staticHeadWeek.find("table").css("margin-left", "0.31rem");
      vm.$boxStaticHead.addClass(
        "el-table newbacktable el-table--fit el-table--border el-table--scrollable-x el-table--enable-row-hover el-table--enable-row-transition"
      );
      vm.$boxStaticHead.append(vm.staticHeadWeek);
    }
  },

  computed: {
    /**
     * 计算课程总天数
     */
    totalDay: function() {
      let dayspan = tool.DaySpan(vm.classInfo.startTime, vm.classInfo.endTime);

      return dayspan;
    }
  },
  mounted() {
    vm = this;
    //监听滚动条
    let scroll = document.getElementById("scroll");
    let rem = screen.width / 19.2;
    vm.$boxStaticHead = $("#box-staticHead");
    // 监听这个dom的scroll事件
    let first = true;
    scroll.addEventListener(
      "scroll",
      () => {
        // debugger
        let height = Number(scroll.scrollHeight);
        let sheight = Number(scroll.scrollTop);
        let h = sheight / rem;
        if (first) {
          vm.addTopStaticDate();
          first = false;
        }
        if (h <= 2.65) {
          vm.$boxStaticHead.css("display", "none");
        } else {
          vm.$boxStaticHead.css("display", "block");
        }
      },
      false
    );
    vm.$store.commit("clearCourselist", []);
  }
};
</script>

<style lang="scss">
@import "@/style/module/utils.scss";
.schedulecalendar {
  width: 100%;
//   #scroll{
// 	  z-index: 2050 !important;
//   }
//   #paike,#conflict,#shuangshi{
// 	  z-index: 3030 !important;
//   }
  #box-staticHead {
    position: fixed;
    display: none;
    left: 3.14rem;
    top: 0;
    width: 15.52rem;
    height: 1.5rem;
    // z-index: 2051;
    background-color: rgb(255, 255, 255);
    border: 0 !important;
    .title_StudentManage.el-row {
      position: relative;
      box-sizing: border-box;
      width: 100%;
      background-color: #f5f7fa;
      padding: 0 0.15rem 0 0.15rem;
      // border-radius: 0.1rem 0.1rem 0 0;
      line-height: 0.5rem;
      font-size: 0.18rem;
      text-align: center;
      .toprow .btn {
        cursor: pointer;
        user-select: none;
      }
      .toprow .timetxt {
        margin: 0.2rem;
        user-select: none;
      }
    }
    .el-table__header-wrapper {
      th,
      td {
        border-right: 0 !important;
        border-bottom: 0 !important;
      }
      .select {
        color: #3885f8;
      }
      .arrow {
        width: 100%;
        text-align: center;
      }
      .dayofweek {
        display: inline-block;
        width: 100%;
        text-align: center;
        font-size: 0.17rem;
      }
      .date {
        display: inline-block;
        width: 100%;
        text-align: center;
      }
    }
  }
  .quickSave {
    cursor: pointer;
    position: absolute;
    z-index: 3000;
    height: 1.46rem;
    width: 1.46rem;
    right: 0.5rem;
    bottom: 3rem;
    opacity: 1;
    background-image: url("~@/assets/img/education_manage/quicksaveicon.png");
    background-size: 1.46rem 1.46rem;
  }
  .quickSaveShow {
    opacity: 1;
    transition: opacity 1s;
    z-index: 3000;
  }
  .quickSaveHide {
    opacity: 0;
    transition: opacity 1s;
    z-index: -1;
  }
  .schedule-box {
    width: 100%;
    height: auto;
    padding: 0.3rem 0.55rem;
    .class-name {
      width: 100%;
      margin-bottom: 0.3rem;
      text-align: center;
    }
    .class-Info {
      table tr {
        height: 0.36rem;
      }
    }
    .line {
      width: 100%;
      height: 1px;
      background: #ebebeb;
      margin-bottom: 0.3rem;
      margin-top: 0.3rem;
    }
    .calendar-content {
      width: 100%;
      display: flex;
      .left-content {
        width: 2.5rem;
        height: auto;
        .el-input__inner {
          border-radius: 5px;
          height: 0.36rem;
          font-size: 0.16rem;
          border: 1px solid #ededed;
        }
        .el-select .el-input .el-select__caret {
          color: #6d7c83;
          font-size: 0.15rem;
        }
        .prefixiconsearch {
          height: 0.15rem;
          width: 0.15rem;
          margin-top: 0.205rem;
          margin-left: 0.1rem;
          background: url("~@/assets/img/common/search_icon.png");
          background-size: cover;
        }

        .condition-box {
          width: 100%;
          max-height: 4rem;
          border: 1px solid #ebebeb;
          margin-bottom: 0.2rem;
          position: relative;
          background-color: rgb(65,107,215);
          border-radius: 0.1rem;
          .condition-list {
            width: 100%;
            max-height: 3.4rem;
            overflow: auto;
            padding: 0rem 0.1rem;
            &::-webkit-scrollbar {
              width: 0.03rem;
              height: 0;
            }
            &::-webkit-scrollbar-thumb {
              border-radius: 0.03rem;
              background: #ededed;
            }
            .condition-li {
              width: 100%;
              height: 0.485rem;
              .spanlabel{
                color: white;
                font-size: 0.18rem;
              }
              .default-icon {
                height: 100%;
                width: 100%;
                text-indent: 0.2rem;
                background-image: url("~@/assets/img/education_manage/check_no.png");
                background-repeat: no-repeat;
                background-size: 0.14rem 0.14rem;
                cursor: pointer;
                line-height: 0.485rem;
                background-position-y: 0.1725rem;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              }
              .yes-icon {
                height: 100%;
                width: 100%;
                text-indent: 0.2rem;
                background: url("~@/assets/img/education_manage/check_green.png");
                background-repeat: no-repeat;
                background-size: 0.14rem 0.14rem;
                cursor: pointer;
                line-height: 0.485rem;
                background-position-y: 0.1725rem;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              }
              .success-icon {
                height: 100%;
                width: 100%;
                text-indent: 0.2rem;
                background: url("~@/assets/img/education_manage/check_gray.png");
                background-repeat: no-repeat;
                background-size: 0.14rem 0.14rem;
                cursor: pointer;
                line-height: 0.485rem;
                background-position-y: 0.1725rem;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              }
            }
          }
        }
      }
      .right-content {
        width: 15.6rem;
        height: auto;
        margin-left: 0.1rem;
        .calendarcontainer {
          margin-left: 0;
          width: 100%;
          height: auto;
          background: #fff;
          border: 0.01rem solid #dcdfe6;
          border-radius: 0.1rem;
          box-shadow: 0 0.02rem 0.38rem 0 #3885f81f, 0 0 0.06rem 0 #3885f81f;
          margin-bottom: 2.3rem;
          .timeselect {
            position: absolute;
            right: 0.2rem;
            top: -0.05rem;
            .el-radio-button__orig-radio:checked + .el-radio-button__inner {
              color: #3885f8;
              font-weight: bold;
              background: #ffffff;
              border: 0.01rem solid #dcdfe6;
              -webkit-box-shadow: 0rem 0 0 0 #ffffff;
              box-shadow: 0rem 0 0 0 #ffffff;
            }
          }
        }
        .box-controls {
          position: fixed;
          margin-left: 0;
          width: 15.52rem;
          height: auto;
          background: #fff;
          // border: 0.01rem solid #dcdfe6;
          z-index: 10;
          bottom: 0;
        }
        .avoid-holiday {
          width: 100%;
          height: 0.3rem;
          display: inline-flex;
          flex-wrap: wrap;
          align-content: center;
          flex-direction: row;
          margin: 0.5rem 0rem 0rem 0rem;
          padding: 0.2rem 0.3rem;
          .el-radio {
            .el-radio__label {
              font-size: 0.16rem;
              font-family: "微软雅黑";
              color: #666666;
            }
          }
        }
        .set-timetable-cycle {
          width: 100%;
          height: 0.3rem;
          display: inline-flex;
          flex-wrap: wrap;
          align-content: center;
          /*  justify-content: center;*/
          flex-direction: row;
          padding: 0.2rem 0.3rem;
          .el-radio {
            .el-radio__label {
              font-size: 0.16rem;
              font-family: "微软雅黑";
              color: #666666;
            }
          }
        }
        .timetable-Application-cycle {
          width: 100%;
          height: 0.3rem;
          display: inline-flex;
          flex-wrap: wrap;
          align-content: center;
          /* justify-content: center;*/
          flex-direction: row;
          padding: 0.2rem 0.3rem;
        }
        .save-timetable-btn {
          width: 100%;
          height: 1rem;
          display: inline-flex;
          flex-wrap: wrap;
          align-content: center;
          justify-content: center;
          flex-direction: row;
          padding: 0.3rem;
          .success {
            width: 1.6rem;
            height: 0.4rem;
            font-size: 0.18rem;
            background: #3885f8;
            color: #ffffff;
            border-radius: 0.1rem;
            text-align: center;
            line-height: 0.4rem;
            cursor: pointer;
            &:hover {
              background: rgba(56, 133, 248, 0.8);
            }
          }
          .info {
            width: 1.6rem;
            height: 0.4rem;
            font-size: 0.18rem;
            background: #ffffff;
            border-radius: 0.1rem;
            color: #333333;
            border: 0.01rem solid #c0c4cc;
            text-align: center;
            line-height: 0.4rem;
            cursor: pointer;
            &:hover {
              background: rgba(56, 133, 248, 0.1);
            }
          }
        }
      }
    }
  }

  .el-dialog__wrapper {
    &::-webkit-scrollbar {
      width: 0.01rem;
      height: 0;
    }
    &::-webkit-scrollbar-thumb {
      border-radius: 0.01rem;
      background: #f3f6fc;
    }
  }

  /**
		 * 自定义对话框样式
		 */
  .el-calenlar-dialog-bg {
    background: #ffffff;
    width: 19.2rem;
    border-radius: 0rem;
    margin: 0vh !important;

    .el-dialog__headerbtn {
      font-size: 0.25rem !important;
    }
    .el-dialog__header {
      padding: 0px;
    }
    .el-dialog__body {
      padding: 0px !important;
    }
    .el-dialog__footer {
      padding: 0.3rem;
      .footer-btn {
        width: 100%;
        text-align: center;
      }
    }
  }

  /**排课选班**/
  .class-scheduling {
    background: #ffffff;
    width: 10rem !important;
    border-radius: 0.1rem;
    .el-dialog__header {
      padding: 0px;
    }
    .el-dialog__body {
      padding: 0px !important;
    }
    .el-dialog__footer {
      padding: 0rem 0.3rem 0.3rem 0.3rem;
      .footer-btn {
        width: 100%;
        text-align: center;
      }
    }

    .select-class-panel {
      width: auto;
      height: auto;
      padding: 0.3rem 0.31rem;
      .title-box {
        width: 100%;
        height: auto;
        font-size: 0.28rem;
        font-weight: bold;
        color: #333333;
        position: relative;
      }
      .scheduling-coursename {
        width: 100%;
        height: auto;
        margin-top: 0.5rem;
      }
      .scheduling-box {
        width: 100%;
        height: auto;
        .scheduling-input-num {
          width: 100%;
          height: auto;
          margin-top: 0.5rem;
          margin-bottom: 0.3rem;
          .el-input__inner {
            height: auto !important;
            line-height: inherit !important;
            border-radius: 0.04rem !important;
          }
        }
        .scheduling-info-box {
          width: 100%;
          height: auto;
          .el-input__inner {
            border-radius: 0.04rem !important;
          }
        }
      }

      .Btn-box {
        width: 100%;
        height: auto;
        margin-top: 0.3rem;
        color: #333333;
        position: relative;
        display: inline-flex;
        justify-content: center;
        .success {
          width: 1.6rem;
          height: 0.4rem;
          font-size: 0.18rem;
          background: #3885f8;
          color: #ffffff;
          border-radius: 0.1rem;
          text-align: center;
          line-height: 0.4rem;
          cursor: pointer;
          &:hover {
            background: rgba(56, 133, 248, 0.8);
          }
        }
        .info {
          width: 1.6rem;
          height: 0.4rem;
          font-size: 0.18rem;
          background: #ffffff;
          border-radius: 0.1rem;
          color: #333333;
          border: 0.01rem solid #c0c4cc;
          text-align: center;
          line-height: 0.4rem;
          cursor: pointer;
          &:hover {
            background: rgba(56, 133, 248, 0.1);
          }
        }
      }
    }
  }

  .conflict-list {
    background: #ffffff;
    width: 12rem !important;
    border-radius: 0.1rem;
    .el-dialog__header {
      padding: 0px;
    }
    .el-dialog__body {
      padding: 0px !important;
    }
    .el-dialog__footer {
      padding: 0rem 0.3rem 0.3rem 0.3rem;
    }
    .conflict-table {
      width: auto;
      height: auto;
      padding: 0.3rem 0.31rem;
      .title-box {
        width: 100%;
        height: auto;
        font-size: 0.28rem;
        font-weight: bold;
        color: #333333;
        position: relative;
      }
      table tr > th,
      td {
        height: 0.42rem;
        border-bottom: 1px solid #ebebeb;
      }
      .conflict-detail {
        margin-top: 0.2rem;
        .conflict {
          width: auto;
        }
      }

      .Btn-box {
        width: 100%;
        height: auto;
        margin-top: 0.3rem;
        color: #333333;
        position: relative;
        display: inline-flex;
        justify-content: center;
        .success {
          width: 1.6rem;
          height: 0.4rem;
          font-size: 0.18rem;
          background: #3885f8;
          color: #ffffff;
          border-radius: 0.1rem;
          text-align: center;
          line-height: 0.4rem;
          cursor: pointer;
          &:hover {
            background: rgba(56, 133, 248, 0.8);
          }
        }
        .info {
          width: 1.6rem;
          height: 0.4rem;
          font-size: 0.18rem;
          background: #ffffff;
          border-radius: 0.1rem;
          color: #333333;
          border: 0.01rem solid #c0c4cc;
          text-align: center;
          line-height: 0.4rem;
          cursor: pointer;
          &:hover {
            background: rgba(56, 133, 248, 0.1);
          }
        }
      }
    }
  }

  /**双师引导图**/
  .double-teacher-dialog {
    background: #ffffff;
    width: 8rem !important;
    border-radius: 0.1rem;
    .el-dialog__header {
      padding: 0px;
    }
    .el-dialog__body {
      padding: 0px !important;
    }
    .el-dialog__footer {
      padding: 0rem 0.3rem 0.3rem 0.3rem;
    }

    .double-teacher-guide {
      padding: 0.5rem 0.8rem;
      cursor: pointer;
      z-index: 3000;
      height: 3rem;
      width: 100%;
      opacity: 1;
      background: #ffffff;
      .Process {
        height: 1.5rem;
        width: 100%;
        position: relative;
        .step-box {
          width: 0.8rem;
          height: 0.8rem;
          float: left;
          .circle {
            height: 0.8rem;
            width: 0.8rem;
            float: left;
            margin-top: 0.4rem;
            border: 1px solid #dddddd;
            border-radius: 100%;
            color: #3c3c3c;
            line-height: 0.8rem;
            text-align: center;
          }
          .circle-active {
            background: #009bf0;
            color: #ffffff;
          }
          .circle-title {
            width: 0.8rem;
            height: 0.3rem;
            float: left;
            text-align: center;
            line-height: 0.3rem;
            font-size: 0.14rem;
          }
          .circle-title-active {
            color: #009bf0;
          }
        }

        .line {
          height: 0.7rem;
          width: 1.06rem;
          float: left;
          margin-top: 0.4rem;
          line-height: 0.7rem;
          color: #dddddd;
          font-size: 0.2rem;
          overflow: hidden;
          white-space: nowrap;
        }
      }
      .btn-box {
        height: 1rem;
        width: 100%;
        position: relative;
        display: flex;
        padding: 0.25rem 0.6rem;
        align-content: center;
        justify-content: center;
        .returnClass {
          width: 1.6rem;
          height: 0.4rem;
          border-radius: 0.1rem;
          text-align: center;
          color: #333333;
          line-height: 0.4rem;
          border: 0.01rem solid #c0c4cc;
          &:hover {
            background: rgba(56, 133, 248, 0.1);
          }
        }
        .next-step {
          width: 1.6rem;
          height: 0.4rem;
          border-radius: 0.1rem;
          text-align: center;
          line-height: 0.4rem;
          background: #3885f8;
          color: #ffffff;
          &:hover {
            background: rgba(56, 133, 248, 0.8);
          }
        }
      }
    }
  }
}
</style>
